<template>
  <div>
      <div class="commentWrapper">
          <div class="meta">
              <img class="avatar" src="/static/jieni.jpg" alt="">
              <div class="info">
                  <div class="name">火星网友</div>
                  <div class="time">2小时前</div>
              </div>
              <div class="btnReply" @click="reply">回复</div>
          </div>
          <!-- 判断是否有父评论，有的话显示出来，并传给子组件 -->
          <commentFloor v-if="commentItem.parent" :floorItem="commentItem.parent"/>
          <div class="commentContent">
              {{commentItem.content}}
          </div>
      </div>
  </div>
</template>

<script>
import commentFloor from '../components/commentFloor'
export default {
    components:{
        commentFloor
    },
    props:[
        'commentItem'
    ],
    methods:{
        reply(){
            this.$emit('reply',{
                id:this.commentItem.id
            })
        }
    }
}
</script>

<style lang="less" scoped>
.commentWrapper{
    border-bottom: 1px solid #eee;
    padding: 5.556vw 2.778vw;
}
.meta{
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    .avatar{
        width: 9.772vw;
        height: 9.772vw;
        border-radius: 50%;
        object-fit: cover;
    }
    .info{
        flex: 1;
        padding-left: 2.778vw;
        .time{
            font-size: 14px;
            color: #888;
        }
    }
    .btnReply{
        font-size: 14px;
        color: #888;
    }
}
.commentContent{
    margin-top: 5.556vw;
}
</style>